<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Object.assign()</title>
    <script type="application/javascript">
        console.log("Object.assign()--------------------------");
        //es6的Object.assign()其实就跟jquery的$.extend()类似
        var obj1 = {
            name : "hhh",
            age : 25
        };
        var obj2 = {
            name : "lhr",
            address : "qweqwe"
        };
        //后面的对象向前面的对象覆盖，缺少的字段补上，相同的字段取后面对象的值
        var obj3 = Object.assign({},obj1,obj2);
        console.log(obj3);

        console.log("Spread Operator 展开运算符------------------------");
        //利用展开运算符也能够实现Object.assign()或者$.extend()的对象合并功能

        obj1 = {
            a : "aa",
            b : "bb",
            c : "cc"
        };
        obj2 = {
            a : "a2",
            d : "d2"
        }

        obj3 = {...obj1,...obj2};
        console.log(obj3);
    </script>
</head>
<body>

</body>
</html>